<?php 
/**
 * Copyright (c) 2010, Slawomir Mazur <mazursllawek@gmail.com>
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions 
 * are met:
 * 
 * o Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * o Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * o Neither the name of the Softisland nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * Enter description here...
 *
 * @package     Cms
 * @copyright   Slawomir Mazur (c) 2010 (http://www.zend.com/zce.php?c=ZEND011643)
 * @license     http://www.opensource.org/licenses/bsd-license.php
 * @author      Slawomir Mazur <mazursllawek@gmail.com>
 */
?>
<?php /* Initialize some heplers */ ?>
<?php $_companyHelper = $this->company() ?>
<?php $_libraryHelper = $this->library() ?>
<?php $_attributeHelper = $this->attribute() ?>
<?php $_year = $this->year ?>

<?php $user = $this->user()->getUser() ?>

<div class="container clear">
	<div class="library-history">
		<h2><?php echo $_companyHelper->getCompanyById($this->companyId)->name ?></h2>
		<div id="emptyValuesSwitcher" class="clear">
			<label><input type="checkbox" />Hide empty values</label>
		</div>
		<?php if (($this->companyId) && (count($this->data) > 0)) : ?>
			<div class="gene-result-list-library">
				<h5>
					<strong>
						<small>
							[<?php echo $this->translate('RefSeq Annotation from') ?>&nbsp; 
							<label><?php echo $_libraryHelper->getLibraryCreatedDateById($this->data[0]['library_id']) ?></label>]
						</small>
					</strong>
					<strong>
						<small>
							<?php if ('' != ($provider = $_libraryHelper->getLibraryProviderById($this->data[0]['library_id']))) : ?>
								<a class="popup-link provider" href="<?php echo $provider ?>">[<?php echo $this->translate('Library design from') ?>&nbsp; 
								<label><?php echo $_libraryHelper->getLibraryDesignedDateById($this->data[0]['library_id']) ?></label>]</a>
							<?php else : ?>
								[<?php echo $this->translate('Library design from') ?>&nbsp; 
								<label><?php echo $_libraryHelper->getLibraryDesignedDateById($this->data[0]['library_id']) ?></label>]
							<?php endif ?>
						</small>
					</strong>
				</h5>		
				<?php if (false !== $this->navigation) : ?>
					<ol class="dater">
						<?php foreach ($this->navigation as $year) : ?>
							<?php if (isset($year['notshow'])) continue; ?>
							<li><a href="<?php echo $this->baseUrl('index/library-history/cid/' . $this->companyId . '/q/' . $this->q . '/aid/' . $this->aid . '/year/' . $year['year']) ?>"><span><em><?php echo $year['year'] ?></em></span></a></li>
						<?php endforeach ?>
					</ol>
				<?php endif ?>				
				<?php foreach ($this->data as $historyEntry) : ?>
					<ul>
						<li class="start-item"></li>
						<?php foreach ($historyEntry as $code => $value) : ?>
							<?php if ($code == 'history_id' || $code == 'library_id') continue; ?>
							
							<?php $attributeName = $_attributeHelper->getAttributeNameByCode($code) ?>
							<?php $attributeValue = (empty($value))? '-' : $value ?>
							<li <?php if ('-' == $attributeValue) : ?>class="emptyvalue"<?php endif ?>>
								
								<?php echo $attributeName ?>:&nbsp;
								<span>
								<?php switch ($code) :
										case 'gene_symbol' : ?>
											<a href="<?php echo $this->baseUrl('index/network/gene/' . $attributeValue . '/library/' . $this->data[0]['library_id']) ?>" title="Known&amp;Predicted Off-target siRNA Interactions of <?php echo $attributeValue ?>"><?php echo $attributeValue ?><img alt="" width="60" class="network" src="<?php echo $this->baseUrl('skin/images/network.png') ?>" /></a>
										<?php break ?>
										<?php case 'gene_id' : ?>
											<a class="popup-link" href="http://www.ncbi.nlm.nih.gov/gene/<?php echo $attributeValue ?>" title="NCBI library, Gene ID: <?php echo $attributeValue ?>"><?php echo $attributeValue ?></a>
										<?php break ?>
										<?php case 'sequence' : ?>
											<?php if ($user) : ?>
												<?php echo $attributeValue ?>
											<?php else : ?>
												<a class="blocked-data" href="<?php echo $this->baseUrl('user/auth/login') ?>">Login</a> or 
												<a class="blocked-data" href="<?php echo $this->baseUrl('index/contact') ?>">Contact us</a> to see this value
											<?php endif ?>
										<?php break ?>
										<?php default: ?>
											<?php echo $attributeValue ?>
										<?php break ?>
								<?php endswitch ?>
								</span>
							</li>
						<?php endforeach ?>
					</ul>
				<?php endforeach ?>
			</div>
		<?php else : ?>
			<h5><?php echo $this->translate('No annotation founded in %s library from %s for this gene',  $_companyHelper->getCompanyById($this->companyId)->name, $_year) ?></h5>
		<?php endif ?>
		<a class="back-link left" href="<?php echo $this->backURL ?>" title="Go back">Back to result</a>
	</div>
</div>
<script type="text/javascript">
//<![CDATA[
	
//]]>
</script>